package ShipIt::Step::MyUploadCPAN;

use warnings;
use strict;
use File::Which;


our $VERSION = '0.02';


use base 'ShipIt::Step';


sub init {
    my ($self, $conf) = @_;
    my $exe;
    $exe = which('cpan-upload-http') || which('cpan-upload');
    die "neither cpan-upload-http nor cpan-upload found\n" unless $exe;
    $self->{exe} = $exe;
}


sub run {
    my ($self, $state) = @_;
    my $distfile =  $state->distfile;
    die "No distfile was created!"             unless $distfile;
    die "distfile $distfile no longer exists!" unless -e $distfile;

    if ($state->dry_run) {
        warn "*** DRY RUN, not uploading to CPAN!\n";
        return;
    }

    system($self->{exe}, $distfile) and die "Upload failed.\n";
}


1;


__END__

{% USE p = PodGenerated %}

=head1 NAME

{% p.package %} - My version of ShipIt::Step::UploadCPAN

=head1 SYNOPSIS

None.

=head1 DESCRIPTION

None yet.

{% PROCESS standard_pod %}

=cut

